package Gui.Dialogs;

import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.GridLayout;

import javax.swing.JDialog;

import Gui.GameFrame;
import Gui.StartOptionsPanel;

public class NewGameOptionsDialog extends JDialog{
	/**
	 * 
	 */
	private static final long serialVersionUID = 6013319482863246261L;
	private static NewGameOptionsDialog ref;
	public static NewGameOptionsDialog getInstance(){
		if(ref == null)
			ref = new NewGameOptionsDialog();
		return ref;
	}
	private NewGameOptionsDialog(){
		super(GameFrame.getInstance(), "New Game Options", ModalityType.DOCUMENT_MODAL);
		
		setLayout(new GridLayout(0, 1, 0, 10));
		setLocationRelativeTo(GameFrame.getInstance());
		add(StartOptionsPanel.getInstance());
		pack();
		// REFACTOR THIS! MAGIC NUMBER
		if(getTitle() != null){
			FontMetrics fm = getFontMetrics(getFont());
			int width = fm.stringWidth(getTitle()) + 75; // MAGIC NUMBER, 75 is size of a "typical" window icon
			width = (int) Math.max(width*1.2, getPreferredSize().getWidth());
			setSize(new Dimension(width, getHeight()));
		}
		setVisible(true);
		setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
		
		
	}
}
